|
1
|
|
|
/** |
|
2
|
|
|
* @file upgrade.js |
|
3
|
|
|
* @author Nils Laumaillé |
|
4
|
|
|
* @version 2.1.27 |
|
5
|
|
|
* @copyright (c) 2009-2011 Nils Laumaillé |
|
6
|
|
|
* @licensing GNU AFFERO GPL 3.0 |
|
7
|
|
|
* @link http://www.teampass.net |
|
8
|
|
|
* |
|
9
|
|
|
* This library is distributed in the hope that it will be useful, |
|
10
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
12
|
|
|
*/ |
|
13
|
|
|
|
|
14
|
|
|
// Function - do a pause during javascript execution |
|
15
|
|
|
function PauseInExecution(millis) |
|
16
|
|
|
{ |
|
17
|
|
|
var date = new Date(); |
|
18
|
|
|
var curDate = null; |
|
|
|
|
|
|
19
|
|
|
|
|
20
|
|
|
do { curDate = new Date(); } |
|
21
|
|
|
while(curDate-date < millis); |
|
22
|
|
|
} |
|
23
|
|
|
|
|
24
|
|
|
//Fonction qui permet d'appeler un fichier qui ex�cute une requete pass�e en parametre |
|
25
|
|
|
function httpRequest(file,data,type) { |
|
26
|
|
|
var xhr_object = null; |
|
27
|
|
|
var is_chrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1; |
|
28
|
|
|
|
|
29
|
|
|
if (document.getElementById("menu_action") != null) { |
|
30
|
|
|
document.getElementById("menu_action").value = "action"; |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
if(window.XMLHttpRequest) { // Firefox |
|
34
|
|
|
xhr_object = new XMLHttpRequest(); |
|
35
|
|
|
} else if(window.ActiveXObject) { // Internet Explorer |
|
36
|
|
|
xhr_object = new ActiveXObject("Microsoft.XMLHTTP"); //Info IE8 now supports => xhr_object = new XMLHttpRequest() |
|
37
|
|
|
} else { // XMLHttpRequest non support? par le navigateur |
|
38
|
|
|
alert("Your browser does not support XMLHTTPRequest objects ..."); |
|
39
|
|
|
return; |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
if (type == "GET") { |
|
43
|
|
|
xhr_object.open("GET", file+"?"+data, true); |
|
44
|
|
|
xhr_object.send(null); |
|
45
|
|
|
} else { |
|
46
|
|
|
xhr_object.open("POST", file, true); |
|
47
|
|
|
xhr_object.onreadystatechange = function() { |
|
48
|
|
|
if(xhr_object.readyState == 4) { |
|
49
|
|
|
eval(xhr_object.responseText); |
|
|
|
|
|
|
50
|
|
|
//Check if query is for user identification. If yes, then reload page. |
|
51
|
|
|
if (data != "" && data !== undefined && data.indexOf('ype=identify_user') > 0 ) { |
|
52
|
|
|
if (is_chrome === true ) PauseInExecution(100); //Needed pause for Chrome |
|
53
|
|
|
if (type == "") { |
|
54
|
|
|
if (document.getElementById('erreur_connexion').style.display == "") { |
|
55
|
|
|
//rise an error in url. This in order to display the eror after refreshing |
|
56
|
|
|
window.location.href="index.php?error=rised"; |
|
57
|
|
|
} else { |
|
58
|
|
|
window.location.href="index.php"; |
|
59
|
|
|
} |
|
60
|
|
|
} else { |
|
61
|
|
|
if (type = "?error=rised") { |
|
62
|
|
|
if (document.getElementById('erreur_connexion').style.display == "none") type = ""; //clean error in url |
|
63
|
|
|
else type = "?error=rised"; //Maintain the ERROR |
|
64
|
|
|
} |
|
65
|
|
|
window.location.href="index.php"+type; |
|
66
|
|
|
} |
|
67
|
|
|
} |
|
68
|
|
|
} |
|
69
|
|
|
} |
|
70
|
|
|
xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded; charset=utf-8"); |
|
71
|
|
|
xhr_object.send(data); |
|
72
|
|
|
} |
|
73
|
|
|
} |